package com.hd.service.test;

import java.util.Date;
import java.util.List;

import com.hd.common.DataPage;
import com.hd.persistence.model.PurchaseRecord;
import com.hd.utils.HdException;

public class PurchaseRecordManagerTestCase extends BaseTest {
	
	//保存实体
//	public void testSavePurchaseRecord() throws HdException {
//		Customer customer = new Customer();
//		customer.setCustomerId(1L);
//		for ( int i = 6; i < 7; i++ ) {
//			PurchaseRecord purchaseRecord = new PurchaseRecord();
//			purchaseRecord.setDepartment("研发部");
//			purchaseRecord.setDirector("唐僧");
//			purchaseRecord.setContactor("小僧");
//			purchaseRecord.setMachineNo("NO99882233" + i);
//			purchaseRecord.setMachineModel("OOXX0");
//			purchaseRecord.setOptionParts("墨盒");
//			purchaseRecord.setPurchaseDate(new Date());
//			purchaseRecord.setPrice(2000);
//			purchaseRecord.setInvoiceNo("949494");
//			purchaseRecord.setSeller("Mr.Right");
//			purchaseRecord.setInstallDate(new Date());
//			purchaseRecord.setRepairman("Mr.Right");
//			purchaseRecord.setSigningForm("临时客户");
//			purchaseRecord.setCreateTimestamp(123456789000L);
//			purchaseRecord.setWarnDate(new Date());
//			purchaseRecord.setWarnContent("警告");
//			purchaseRecord.setCounter(0);
//			purchaseRecord.setCustomer(customer);
//			purchaseManager.savePurchaseRecord(purchaseRecord);
//			System.out.println(purchaseRecord.getPurchaseRecordId());
//		}
//	}
	
	//分页查询
//	public void testPageQueryPurchaseRecords() throws HdException {
//		DataPage<PurchaseRecord> dataPage = purchaseManager.pageQueryPurchaseRecords(1, 10);
//		System.out.println("查询总数为:" + dataPage.getTotalCount());
//		List<PurchaseRecord> purchaseRecords = dataPage.getData();
//		for ( PurchaseRecord purchaseRecord : purchaseRecords ) {
//			System.out.println(purchaseRecord.getPurchaseRecordId() + " " + purchaseRecord.getDepartment());
//		}
//	}
	
	//根据条件分页查询
	public void testPageQueryPurchaseRecords2() throws HdException {
		DataPage<PurchaseRecord> dataPage = purchaseManager.pageQueryPurchaseRecords(1L, new Date(), new Date(), "机器型号", 1, 100);
		System.out.println("查询总数为:" + dataPage.getTotalCount());
		List<PurchaseRecord> purchaseRecords = dataPage.getData();
		for ( PurchaseRecord pr : purchaseRecords ) {
			System.out.println(pr.getDepartment() + "\t" + pr.getCustomer().getCustomerId() + "\t" + pr.getCustomer().getUnitName());
		}
	}

}
